package friend

import (
	"github.com/gin-gonic/gin"
	"net/http"
	"project-im/internal/model/service"
	"strconv"
)

func DeleteFriend(c *gin.Context) {
	value, _ := c.Get("userId")
	s := value.(int64)
	param := c.Param("id")
	friendId, _ := strconv.Atoi(param)

	friendDelete := service.FriendDelete(int(s), friendId)

	if friendDelete != "" {
		c.JSON(http.StatusBadRequest, gin.H{
			"code":    400,
			"message": "删除失败",
		})
		return
	}

	c.JSON(http.StatusOK, gin.H{
		"code":    200,
		"message": "删除成功",
		"data":    nil,
	})
}
